/*************************************************************************
	> File Name: ProdCon.hpp
	> Author: H.M. Lau
	> Mail: hm.lau@outlook.com
	> Created Time: 2023/09/28 16:37
 ************************************************************************/

#pragma once

#include "comm.hpp"
#include "RingQueue.hpp"

void* producer(void *args)
{
    RingQueue<DATA> *rq = (RingQueue<DATA>*)args;
    while (1) {
        DATA d = 1;
        rq->push(d);
        std::cout << "[" << pthread_self() << "]" << "have produced:" << d << std::endl;
        sleep(3);
    }
}

void* consumer(void *args)
{
    RingQueue<DATA> *rq = (RingQueue<DATA>*)args;
    while (1) {
        DATA d;
        rq->pop(&d);
        std::cout << "[" << pthread_self() << "]" << "have processed:" << d << std::endl;
        sleep(1);
    }
}
